﻿<UserControl x:Class="HTR.Views.CamaraInspeccionView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:viewModel="clr-namespace:HTR.ViewModels"
             mc:Ignorable="d" Width="300">
    
    <UserControl.DataContext>
        <viewModel:CamaraInspeccionViewModel />
    </UserControl.DataContext>

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="AppResources.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <Storyboard x:Key="ExpandMainContent">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="MainContent">
                    <SplineDoubleKeyFrame KeyTime="0" Value="0"/>
                    <SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="152"/>
                </DoubleAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MainContent">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Static Visibility.Visible}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ExpandButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Static Visibility.Collapsed}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="CollapseButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Static Visibility.Visible}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>

            <Storyboard x:Key="CollapseMainContent">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="MainContent">
                    <SplineDoubleKeyFrame KeyTime="0" Value="152"/>
                    <SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="CollapseButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Static Visibility.Collapsed}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ExpandButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Static Visibility.Visible}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </ResourceDictionary>
    </UserControl.Resources>

    <UserControl.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource CollapseMainContent}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="CollapseButton">
            <BeginStoryboard Storyboard="{StaticResource CollapseMainContent}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="ExpandButton">
            <BeginStoryboard Storyboard="{StaticResource ExpandMainContent}"/>
        </EventTrigger>
    </UserControl.Triggers>

    <StackPanel>
        <!-- Encabezado -->
        <Border x:Name="Header" Background="{StaticResource BackgroundBrush}" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1,1,1,0" CornerRadius="5,5,0,0">
            <DockPanel x:Name="TitleHeader">
                <Button x:Name="ExpandButton" VerticalAlignment="Center" Margin="5,5,5,5" Style="{StaticResource ResourceKey=ExpandButtonStyle}" DockPanel.Dock="Right" />
                <Button x:Name="CollapseButton" VerticalAlignment="Center" Margin="5,5,5,5" Style="{StaticResource ResourceKey=CollapseButtonStyle}" DockPanel.Dock="Right" />
                <TextBlock Text="Cámara de Inspección" TextWrapping="Wrap" Margin="15,5,10,5" Foreground="{StaticResource HeaderFontColor}" FontSize="14" 
                           VerticalAlignment="Center" FontWeight="Bold" x:Name="HeaderTextBlock" />
            </DockPanel>
        </Border>

        <!-- Contenido -->
        <Border x:Name="MainContent" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1,0,1,0" Height="152">
            <Grid Margin="0,0,0,0" x:Name="ContentGrid" Background="{StaticResource PanelGradientBrush}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.5*"/>
                    <ColumnDefinition Width="0.5*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="52"/>
                    <RowDefinition Height="48"/>
                    <RowDefinition Height="50"/>
                </Grid.RowDefinitions>

                <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2" HorizontalAlignment="Center">
                    <Canvas x:Name="Dibujo" Width="50" Height="50" Background="#FF212830" Margin="0,2,0,0">
                        <Path x:Name="EjeX" Width="51" Height="1" Canvas.Left="-0.5" Canvas.Top="34.5" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF3B4156" Data="F1 M 0,35L 50,35"/>
                        <Path x:Name="EjeY" Width="1" Height="51" Canvas.Left="14.5" Canvas.Top="-0.499996" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF3B4156" Data="F1 M 15,50L 15,3.8147e-006"/>
                        <Ellipse x:Name="Circulo" Width="22" Height="22" Canvas.Left="4" Canvas.Top="24" Stretch="Fill" StrokeThickness="2" StrokeLineJoin="Round" Stroke="#FFFF7F7F"/>
                        <Viewbox x:Name="CI" Width="12.467" Height="10.8667" Canvas.Left="8.76651" Canvas.Top="29.5667">
                            <Canvas Width="12.467" Height="10.8667">
                                <Path x:Name="LetraC" Width="9.26691" Height="10.8667" Canvas.Left="0" Canvas.Top="0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFF7F7F" Fill="#FFFF7F7F" Data="F1 M 7.43354,6.86458L 8.76691,7.18333C 8.50718,8.21806 8.0405,9.00729 7.36687,9.55104C 6.69324,10.0948 5.8696,10.3667 4.89596,10.3667C 3.8876,10.3667 3.06778,10.1573 2.43652,9.73854C 1.80525,9.31979 1.32468,8.71354 0.994806,7.91979C 0.664936,7.12604 0.5,6.27361 0.5,5.3625C 0.5,4.36806 0.683686,3.50105 1.05106,2.76146C 1.41843,2.02188 1.94101,1.46007 2.61881,1.07604C 3.29661,0.692015 4.04247,0.5 4.85638,0.5C 5.77863,0.5 6.55469,0.742361 7.18457,1.22708C 7.81445,1.71181 8.25301,2.39306 8.50023,3.27084L 7.16686,3.56458C 6.9613,2.86875 6.66233,2.36181 6.26996,2.04375C 5.87759,1.72569 5.38487,1.56667 4.79179,1.56667C 4.10844,1.56667 3.53759,1.74306 3.07924,2.09583C 2.6209,2.44861 2.29866,2.92222 2.11255,3.51667C 1.92643,4.11111 1.83337,4.72361 1.83337,5.35417C 1.83337,6.16945 1.94622,6.88055 2.17192,7.4875C 2.39763,8.09444 2.74833,8.54826 3.22404,8.84896C 3.69975,9.14965 4.21539,9.3 4.77096,9.3C 5.44459,9.3 6.01544,9.09549 6.48351,8.68646C 6.95158,8.27743 7.26825,7.67014 7.43354,6.86458 Z "/>
                                <Rectangle x:Name="LetraI" Width="2.33337" Height="10.6" Canvas.Left="10.1336" Canvas.Top="0.133333" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FFFF7F7F" Fill="#FFFF7F7F"/>
                            </Canvas>
                        </Viewbox>
                        <Viewbox x:Name="Cota" Width="22.0528" Height="22.5048" Canvas.Left="19.2893" Canvas.Top="2.10548">
                            <Canvas Width="22.0528" Height="22.5048">
                                <Path x:Name="Num1" Width="5.34572" Height="5.34573" Canvas.Left="1.90735e-006" Canvas.Top="17.1591" Stretch="Fill" Fill="#FFFFFF00" Data="F1 M 5.34573,21.9109L 4.75176,22.5048L 1.04873,18.8018C 1.0391,19.0782 0.985138,19.3992 0.886831,19.765C 0.788525,20.1307 0.680248,20.4394 0.562004,20.691L 1.90735e-006,20.129C 0.17943,19.6443 0.284784,19.1687 0.316063,18.7023C 0.347343,18.2359 0.312454,17.849 0.211397,17.5417L 0.593971,17.1591L 5.34573,21.9109 Z "/>
                                <Path x:Name="Num2" Width="6.99963" Height="7.01918" Canvas.Left="2.83386" Canvas.Top="13.5058" Stretch="Fill" Fill="#FFFFFF00" Data="F1 M 9.23952,16.8291L 9.8335,17.4231L 6.73166,20.5249C 6.58385,20.3854 6.46698,20.2252 6.38105,20.0444C 6.23737,19.7495 6.14559,19.415 6.10572,19.0411C 6.06585,18.6671 6.07925,18.1869 6.14594,17.6005C 6.22018,16.6614 6.22499,15.9887 6.16037,15.5824C 6.09575,15.1761 5.9531,14.8626 5.73243,14.642C 5.51244,14.422 5.24622,14.3173 4.93376,14.328C 4.62131,14.3386 4.33549,14.4735 4.07632,14.7327C 3.80202,15.007 3.65834,15.3023 3.64528,15.6185C 3.63222,15.9347 3.75906,16.2283 4.02579,16.4992L 3.36583,17.0271C 2.97672,16.5569 2.80107,16.0777 2.83889,15.5896C 2.8767,15.1015 3.11731,14.6358 3.56072,14.1924C 4.00895,13.7441 4.48932,13.5154 5.00182,13.5061C 5.51433,13.4968 5.95654,13.6781 6.32846,14.0501C 6.51751,14.2391 6.66789,14.4603 6.77961,14.7136C 6.89132,14.967 6.96608,15.2768 7.00389,15.6433C 7.0417,16.0097 7.03173,16.5669 6.97399,17.3148C 6.91418,17.9466 6.88083,18.368 6.87396,18.5791C 6.86709,18.7901 6.8798,18.9826 6.91212,19.1565L 9.23952,16.8291 Z "/>
                                <Path x:Name="Num4" Width="5.14774" Height="6.26968" Canvas.Left="7.8536" Canvas.Top="9.56951" Stretch="Fill" Fill="#FFFFFF00" Data="F1 M 12.4074,14.8492L 11.2854,13.7273L 9.17353,15.8392L 8.57956,15.2452L 7.8536,10.0315L 8.31557,9.56951L 11.2854,12.5394L 11.8794,11.9454L 12.4734,12.5394L 11.8794,13.1333L 13.0013,14.2553L 12.4074,14.8492 Z M 10.6915,13.1333L 8.85798,11.2999L 9.30655,14.5182L 10.6915,13.1333 Z "/>
                                <Path x:Name="Num3" Width="6.12169" Height="6.03507" Canvas.Left="10.3622" Canvas.Top="6.20697" Stretch="Fill" Fill="#FFFFFF00" Data="F1 M 13.0013,11.7474L 13.5293,11.0874C 13.8978,11.3267 14.2216,11.4408 14.5007,11.4298C 14.7798,11.4188 15.0421,11.2906 15.2875,11.0452C 15.5755,10.7571 15.7139,10.4355 15.7026,10.0805C 15.6912,9.72539 15.5505,9.41277 15.2803,9.14259C 15.0225,8.88479 14.7248,8.75658 14.3873,8.75796C 14.0497,8.75933 13.7503,8.89064 13.4891,9.15187C 13.3825,9.25843 13.2708,9.41277 13.154,9.61488L 12.6889,9.02401C 12.7315,8.991 12.7638,8.96351 12.7858,8.94151C 13.012,8.71533 13.154,8.44997 13.2117,8.14542C 13.2694,7.84088 13.1701,7.56039 12.9137,7.30397C 12.7109,7.10117 12.4756,7.00028 12.2078,7.00131C 11.9401,7.00234 11.7,7.10907 11.4875,7.3215C 11.2772,7.53186 11.1679,7.77316 11.1596,8.0454C 11.1514,8.31763 11.2593,8.60568 11.4834,8.90954L 10.8234,9.43752C 10.4941,8.97073 10.3412,8.50669 10.3646,8.0454C 10.3879,7.58411 10.5801,7.173 10.941,6.81209C 11.1899,6.56322 11.474,6.38912 11.7933,6.28979C 12.1126,6.19044 12.423,6.18048 12.7245,6.25988C 13.0259,6.33928 13.2835,6.48589 13.4973,6.69968C 13.7001,6.90249 13.8301,7.14207 13.8871,7.41843C 13.9442,7.69479 13.9146,7.98937 13.7984,8.30217C 14.1422,8.08768 14.4983,7.99934 14.8668,8.03715C 15.2353,8.07496 15.5721,8.24648 15.8773,8.55172C 16.2898,8.9642 16.4919,9.46158 16.4837,10.0439C 16.4754,10.6261 16.2458,11.1428 15.7948,11.5938C 15.3879,12.0007 14.9274,12.2161 14.4136,12.2398C 13.8997,12.2635 13.4289,12.0994 13.0013,11.7474 Z "/>
                                <Path x:Name="Punto" Width="1.18794" Height="1.18794" Canvas.Left="17.6211" Canvas.Top="7.8536" Stretch="Fill" Fill="#FFFFFF00" Data="F1 M 18.2151,9.04153L 17.6211,8.44756L 18.2151,7.8536L 18.809,8.44756L 18.2151,9.04153 Z "/>
                                <Path x:Name="Num5" Width="6.34113" Height="6.71247" Canvas.Left="15.6412" Canvas.Top="0" Stretch="Fill" Fill="#FFFFFF00" Data="F1 M 18.545,6.20368L 19.073,5.54371C 19.4016,5.78432 19.7118,5.9024 20.0037,5.89793C 20.2955,5.89346 20.5648,5.76783 20.8116,5.52103C 21.1148,5.21785 21.2487,4.87773 21.2133,4.50066C 21.1779,4.12358 20.9897,3.76456 20.6487,3.42357C 20.3249,3.09978 19.9891,2.92447 19.6412,2.89766C 19.2934,2.87085 18.9592,3.01762 18.6389,3.33798C 18.4388,3.53803 18.3154,3.74702 18.2687,3.96495C 18.2219,4.18288 18.2261,4.40115 18.2811,4.61976L 17.6211,5.14774L 15.6412,2.24389L 17.8851,0L 18.4791,0.593967L 16.725,2.34804L 17.7273,3.80408C 17.7933,3.33111 17.9745,2.94647 18.2708,2.65018C 18.6626,2.25832 19.1371,2.0715 19.6943,2.08972C 20.2515,2.10793 20.7559,2.34288 21.2076,2.79454C 21.638,3.22489 21.8892,3.71746 21.9614,4.27225C 22.0528,4.95078 21.8445,5.54406 21.3365,6.05209C 20.9199,6.4687 20.4595,6.68817 19.9552,6.71051C 19.451,6.73286 18.9809,6.56391 18.545,6.20368 Z "/>
                            </Canvas>
                        </Viewbox>
                    </Canvas>
                </StackPanel>

                <StackPanel Grid.Row="1" Margin="10,0,0,0">
                    <Label Content="Cota de Terreno" />
                    <TextBox TextWrapping="Wrap" x:Name="CotaTerrenoInputTextBox" HorizontalAlignment="Left" Margin="5,0,0,0" TabIndex="100" Width="100"
                             Text="{Binding Path=CotaTerrenoText, Mode=TwoWay}" IsEnabled="{Binding Path=CotaTerrenoIsEnabled}"  />
                </StackPanel>

                <StackPanel Grid.Row="2" Grid.ColumnSpan="2" Margin="15,15,15,15" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Stretch">
                    <Button Content="Insertar" x:Name="InsertarButton" VerticalAlignment="Bottom" HorizontalAlignment="Left" TabIndex="110"
                            Command="{Binding Path=InsertarCamaraInspeccionCmd}" ClickMode="Press" IsEnabled="{Binding Path=InsertarIsEnabled}" Visibility="{Binding Path=NonEditVisibility}"/>
                    <Button Content="Modificar" x:Name="ModificarButton" VerticalAlignment="Bottom" HorizontalAlignment="Left" TabIndex="130"
                            Command="{Binding Path=ModificarCamaraInspeccionCmd}" ClickMode="Press" Margin="15,0,0,0" IsEnabled="{Binding Path=ModificarIsEnabled}" Visibility="{Binding Path=NonEditVisibility}" />
                    <Button Content="Aceptar" x:Name="AceptarButton" VerticalAlignment="Bottom" HorizontalAlignment="Left" TabIndex="140"
                            Command="{Binding Path=AceptarModifCamaraInspCmd}" ClickMode="Press" Visibility="{Binding Path=EditVisibility}" />
                    <Button Content="Cancelar" x:Name="CancelarButton" VerticalAlignment="Bottom" IsCancel="True" HorizontalAlignment="Left" TabIndex="150"
                            Command="{Binding Path=CancelarModifCamaraInspCmd}" ClickMode="Press" Margin="15,0,0,0" Visibility="{Binding Path=EditVisibility}"
                            Style="{StaticResource RedButtonStyle}" />
                </StackPanel>
            </Grid>
        </Border>

        <!-- Pie -->
        <Border x:Name="Footer" Background="{StaticResource BackgroundBrush}" Height="10" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1,0,1,1" CornerRadius="0,0,5,5" />

    </StackPanel>
</UserControl>
